package com.hzyl.famousreader.view.adapter;

import android.support.annotation.Nullable;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.hzyl.famousreader.R;
import com.hzyl.famousreader.repository.webservice.model.Classification;

import java.util.List;

/**
 * 书籍分类
 */
public class ClassificationAdapter extends BaseQuickAdapter<Classification, BaseViewHolder> {

  private Long curSelectedId;

  public ClassificationAdapter(@Nullable List<Classification> data) {
    super(R.layout.item_classification, data);
  }

  public void setCurSelectedId(Long curSelectedId) {
    this.curSelectedId = curSelectedId;
  }

  @Override
  protected void convert(BaseViewHolder helper, Classification item) {


    helper.setText(R.id.classification_tv_name, item.getName());
    if(curSelectedId == item.getId()) {
      helper.setTextColor(R.id.classification_tv_name, mContext.getResources().getColor(R.color.text_sky_blue));
      helper.setBackgroundColor(R.id.classification_tv_name, mContext.getResources().getColor(R.color.bg_white));
    } else {
      helper.setTextColor(R.id.classification_tv_name, mContext.getResources().getColor(R.color.half_transparent));
      helper.setBackgroundColor(R.id.classification_tv_name, mContext.getResources().getColor(R.color.transparent));
    }
  }
}
